package com.example.hello_word.controller;


import com.example.hello_word.bean.User;
import com.example.hello_word.mapper.UserMapper;
import com.mysql.cj.log.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class UserController {

    @Autowired
    UserMapper userMapper;

    @RequestMapping("/user")
    @ResponseBody
    public List<User> userMapper(Model m){
        List<User> users = userMapper.findAll();
        for (int i = 0; i < users.size(); i++) {
            System.out.println("数据库里面的名字===>"+users.get(i).getLastname());
        }
        return users;
    }


}
